<script type="text/javascript" src="/js/urlcheck.js"></script>
<script type="text/javascript">

$("#error").hide();
$("#error1").hide();
$("#error2").hide();
$("#pleasewait").hide();
</script>

<div class="content_top">
<div class="cor_lf_t"></div>
<div class="cor_rt_t"></div>
</div>
<p><!--do not touch this, this is for image--></p>
<p><!--
<div class="viewport">--></p>
<div class="container" align="center">
<div id="fb-root"></div>
<script>
	
	//-------- for facebook login --------//
	window.fbAsyncInit = function() {
		// init the FB JS SDK
		FB.init({
		  appId      : '325576574237405',                        // App ID from the app dashboard
		  channelUrl : 'http://www.myanmarsme.com', 				// Channel file for x-domain comms
		  status     : true,                                 // Check Facebook Login status
		  xfbml      : true                                  // Look for social plugins on the page
		});
	  };

	  // Load the SDK asynchronously
	  (function(d, s, id){
		 var js, fjs = d.getElementsByTagName(s)[0];
		 if (d.getElementById(id)) {return;}
		 js = d.createElement(s); js.id = id;
		 js.src = "//connect.facebook.net/en_US/all.js";
		 fjs.parentNode.insertBefore(js, fjs);
	   }(document, 'script', 'facebook-jssdk'));
    
	/* -----------------------------------
		when click login with facebook button, 
		facebook login function check and get the email from facebook, 
		and call authenticate_api function for checking the email is valid or not.
	--------------------------------------*/	
	document.getElementById('fb-login').onclick = function() {
		$.cookies.del("session");
		  FB.login(function(response) {
			if (response.authResponse) {
				var token = response.authResponse.accessToken;
				accessToken = token;
				FB.api('/me?access_token=' + token + '', function (response) {
					authenticate_api(response.email, response.name);
				});
			}
		 },{scope: 'email'});
		};
	
	//-------- for google plus login --------//
	function loginFinishedCallback(authResult) {
		$.cookies.del("session");
		if (authResult) {
		  if (authResult['error'] == undefined){
			gapi.auth.setToken(authResult); // Store the returned token.
			toggleElement('signin-button'); // Hide the sign-in button after successfully signing in the user.
			getEmail();                     // Trigger request to get the email address.
		  } else {
			console.log('An error occurred');
		  }
		} else {
		  console.log('Empty authResult');  // Something went wrong
		}
	}
	
	//-------- get user info --------//
	function getEmail(){
		// Load the oauth2 libraries to enable the userinfo methods.
		gapi.client.load('oauth2', 'v2', function() {
			  var request = gapi.client.oauth2.userinfo.get();
			  request.execute(getEmailCallback);
			});
	}
	
	//-------- get email from user info --------//
	function getEmailCallback(obj){
		authenticate_api(obj['email']);
	}
</script>
<img src="/images/1facebook_login.png" id="fb-login" align="right" style="cursor: pointer;">
<div id="signin-button" class="show">
 <div class="g-signin" data-callback="loginFinishedCallback"
  data-approvalprompt="force"
  data-clientid="841077041629.apps.googleusercontent.com"
  data-scope="https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/userinfo.email"
  data-height="short"
  data-cookiepolicy="single_host_origin">
</div>
</div>
<div id="signin-wrapper">
<table id="sign-in-box" width="250" border="0" cellpadding="7" cellspacing="0" align="center">
    <tbody>
        <tr>
            <td style="width:250px;" valign="top" align="left">
                Email<br />
                <input name="text" type="text" style="width:200px;float:left;font-size:14px;padding:3px;" /> 
                <span id="error1" style="width:100%;float:left;color:red;font-size:11px;">Enter your email address !</span>
            </td>
        </tr>
        <tr>
            <td valign="top" align="left">
                Password<br />
                <input name="password" type="password" style="width:200px;float:left;font-size:14px;padding:3px;" onkeydown="enterKey(event,function() { authenticate(); })" /> <span id="error2" style="color:red;float:left;width:100%;font-size:11px;">Enter your password !</span>
            </td>
        </tr>
        <tr>
            <td valign="bottom">
            	<a href="javascript:authenticate()" class="button" style="float:left;margin-right:10px;">sign in</a>
            	<a href="javascript:goto(navigation.recover) " style="color:blue;font-size:11px;float:left;padding-top:5px;">Forgot Password ?</a>
            </td>
        </tr>
        <!--<tr>
            <td valign="bottom" align="left"> <a href="javascript:goto(navigation.recover) " style="color:blue;">Forgot Password ?</a></td>
        </tr>-->
    </tbody>
</table>
</div>
<p id="pleasewait" style="color:green;clear:both;margin-top:10px;text-align:center;width:100%;">Loading Please Wait.</p>
<p id="error" style="color:red;clear:both;margin-top:10px;text-align:center;width:100%;">The username or password you entered is incorrect.</p>
</div>
<div class="content_btm">
<div class="cor_lf_b"></div>
<div class="cor_rt_b"></div>
</div>